package com.zjht.aop;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class TimePointCut implements InvocationHandler {

    private Object targetObject;


    public Object createProxyIntance(Object targetObject) {
        this.targetObject = targetObject;
        return Proxy.newProxyInstance(this.targetObject.getClass().getClassLoader(), this.targetObject.getClass().getInterfaces(), this);
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //PersonServiceBean bean = (PersonServiceBean) this.targetObject;
        Object result = null;
        System.out.println("#==start==#");
        result = method.invoke(targetObject, args);
        System.out.println("#==end==#");
        return result;
    }

}
